<template>
    <orh-table>
        <div slot="option">
            <Button type="primary" @click="modal1other=true" size="small">筛选条件</Button>
            <Button type="primary" @click="printingClick" size="small">打印</Button>
        </div>
        <list :printing="printing" @print-end="printEnd" :datalist="datalist" :columnstype="columnstype" :tableload="tableload" slot="table" @on-look-fun="Detail"></list>
        <Modal
            v-model="modal1other"
            title="筛选条件"
            slot="others">
            <p> 
            <condition @on-condition="onCondition" @modal1="modal1=>modal1other=modal1"></condition>
            <div slot="footer">
                <Button @click="modal1other=false" long>取消</Button>
            </div>
            </p>
        </Modal> 
        <orh-sidebar v-model="isShow" :title="`${titles}`" cover slot="others"> 
            <detail v-if="isShow" :conditiones="conditiones"></detail>
        </orh-sidebar>
    </orh-table>
</template>

<script>   
  export default {
    name: "teacher-myattendancerecorddata",
    components: {
		Detail: resolve => {require(['../Public/AttendanceList/Detail.vue'], resolve);},
		List: resolve => {require(['../Public/AttendanceList/List.vue'], resolve);},
		Condition: resolve => {require(['../Public/AttendanceList/Condition.vue'], resolve);},
    },
    data () {
      return {
            columnstype:false,
            sss:new Date(),
            // 列表接口请求携带参数
            condition:{
                month:null,
                semester_id:null,
            },
            conditiones:null,
            isShow:false,
            tableload:false,
            tableHeight:0,
            titles:'',
            modal1other:false,
            datalist:[],//荣誉变量
            printing:false,
             
            listUrl:'api/teacher/v1/get/teacher/user/userlist',//

        }
    },
    methods: {

        /************************************************************
         * 
         * 获取教师数据
         * 
         ************************************************************/
        queryData(){
            this.tableload=true
            this.$http.get(this.listUrl).then(val=>{
                this.datalist = []
                this.datalist.push(val.data)
                this.tableload=false//加载完数据动画结束  
            }).catch(err=>{
                if(err.code && err.code==422) {
                    this.$Message.error(err.message);
                }
                this.tableload = false;
            })

        },
       

        Detail(row){
            this.conditiones={
                user_id:row.user_id,
                month:this.condition.month
            }
            this.titles=row.titles
            this.isShow=row.isShow
        },
        onCondition(type,data){
            this.modal1other=false
            this.condition=data
            if(type=='month'){
                this.columnstype = false
                this.listUrl=`api/teacher/v1/get/teacher/user/userlist?type=month&month=${this.condition.month}`
            }
            if(type=='semester'){
                this.columnstype = 'semester'
                this.listUrl=`api/teacher/v1/get/teacher/user/userlist?type=semester&semester_id=${this.condition.semester_id}`
            }
            this.queryData()
        },
        /************************************************************
         * 
         * 打印数据
         * 
         ************************************************************/
        printingClick () {
            this.printing=true
        },

        /************************************************************
         * 
         * 打印数据结束后
         * 
         ************************************************************/
        printEnd(data){
            this.printing=data
        }
    },
    mounted(){
        this.condition.month=new Date().toISOString().substr(0, 7)
        this.listUrl=`api/teacher/v1/get/teacher/user/userlist?type=month&month=${this.condition.month}`
        this.queryData()
    }
  }
</script>